package cs.uns.edu.ar.aygps.service;

import java.net.URL;
import java.util.Map;

import cs.uns.edu.ar.aygps.model.exception.AyGPSException;

public abstract class ModelService {
	
	protected String performingService;
	
	protected Map serviceData;
	
	public ModelService(String service) {
		performingService = service;
	}

	public abstract void executeService() throws AyGPSException;
	
	public String getServiceDataConfigurator() throws AyGPSException {
		ClassLoader loader = Thread.currentThread().getContextClassLoader();
		URL url= loader.getResource(getConfigFilePath());
		if (url != null)
			return getConfigFilePath();
		else
			throw new AyGPSException(AyGPSException.CONF_FILE_NOT_FOUND);
	}

	private String getConfigFilePath() {
		return performingService + ".xml";
	}
	
	public void setServiceData(Map sd){
		serviceData = sd;
	}
}
